/**
 * Treatments.java
 * Copyright (C) 2009 Jose Mauro da Silva Sandy
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

package plagio.utils;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.FileInputStream;
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Vector;

/**
 * @author jmsandy
 */
public class Treatments {
    private ArrayList listFiles;
    private Vector listStream = new Vector();
    private Integer lengthFiles;

    public Treatments(ArrayList listFiles){
        this.listFiles = listFiles;
    }

    public boolean convFilesBin(){
        boolean convOk = true;
        try{
            for(int i = 0; i < listFiles.size(); i++){
                Vector file = (Vector)listFiles.get(i);
                InputStream stream = new FileInputStream(
                        file.elementAt(3).toString());
                InputStreamReader is = new InputStreamReader(stream);
                BufferedReader br = new BufferedReader(is);

                String str = null;
                while(br.ready()) str += br.readLine();
                this.listStream.add(str.getBytes());
                // this.lengthFiles += file.size();
            }
        }catch(Exception e) {
            this.lengthFiles = 0;
            this.listStream.clear();
            convOk = false;
            e.printStackTrace();
        }
        return convOk;
    }

    /**
     * @return the listStream
     */
    public Vector getListStream() {
        return listStream;
    }

    /**
     * @param listStream the listStream to set
     */
    public void setListStream(Vector listStream) {
        this.setListStream(listStream);
    }

    /**
     * @return the lengthFiles
     */
    public Integer getLengthFiles() {
        return lengthFiles;
    }

    /**
     * @param lengthFiles the lengthFiles to set
     */
    public void setLengthFiles(Integer lengthFiles) {
        this.lengthFiles = lengthFiles;
    }
}
